package life;

import java.util.Arrays;

// 判断数组是否是等差数列
public class IsPalindromic {
    public static void main(String[] args) {
        int[] data={1,2,3,4};
        int[] f = new int[3];
        System.arraycopy(data,1,f,0,3);
        System.out.println(Arrays.toString(f));
        System.out.println(isPalindromic(f, 0, f.length));

    }

    private static boolean isPalindromic(int[] data, int i, int j) {
        Arrays.sort(data);
        int p = i;
        int q = i + 1;
        int d = data[q] - data[p];
        for (int k = p + 1; k < j; k++) {
            if (data[k] != d * (k) + data[i]) {
                return false;
            }
        }
        return true;
    }

}
